package test11To20;

import java.util.Scanner;
import java.util.regex.Pattern;

public class Test20 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String s = scanner.nextLine();
            if (s.length()<9){
                System.out.println("NG");
                continue;
            }

            if(getMatch(s)){
                System.out.println("NG");
                continue;
            }

            if (getStr(s,0,3)){
                System.out.println("NG");
                continue;
            }

            System.out.println("OK");
        }
    }

    private static boolean getStr(String str, int i, int l) {
        if (l>=str.length()){
            return false;
        }

        if (str.substring(l).contains(str.substring(i, l))) {
            return true;
        } else {
            return getStr(str,i+1,l+1);
        }
    }

    private static boolean getMatch(String s) {

        int count =0;
        Pattern p1 = Pattern.compile("[A-Z]");
        boolean c = p1.matcher(s).find();
        if (c){
            count++;
        }

        p1 = Pattern.compile("[a-z]");
        c = p1.matcher(s).find();
        if (c){
            count++;
        }
        p1 = Pattern.compile("[0-9]");
        c = p1.matcher(s).find();
        if (c){
            count++;
        }
        p1 = Pattern.compile("[^0-9A-Za-z]");
        c = p1.matcher(s).find();
        if (c){
            count++;
        }

        return count < 3;
    }
}
